﻿using System;

namespace Present.Commands.Async.Actions.Decorators
{
    public abstract class AsyncActionDecorator<TParameter, TResult> : AsyncAction<TParameter, TResult>
    {
        protected readonly IAsyncAction<TParameter, TResult> InnerTarget;

        protected AsyncActionDecorator(IAsyncAction<TParameter, TResult> innerTarget)
        {
            this.InnerTarget = innerTarget;
        }

        public override void HandleSuccess(TResult result)
        {
            InnerTarget.HandleSuccess(result);
        }

        public override void HandleError(Exception error)
        {
            InnerTarget.HandleError(error);
        }

        public override TResult DoWork(ActionExecution<TParameter> args)
        {
            return InnerTarget.DoWork(args);
        }

        public override ActionExecution<TParameter> PrepareWork(TParameter parameter)
        {
            return InnerTarget.PrepareWork(parameter);
        }

        public override bool CanExecute(object parameter)
        {
            return InnerTarget.CanExecute(parameter);
        }
    }
}